package com.laborer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.laborer.entity.User;
import com.laborer.mapper.UserMapper;
import com.laborer.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 用户
 * @Author: jeecg-boot
 * @Date:   2021-06-08
 * @Version: V1.0
 */
@Service
@Primary
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {


    @Override
    public boolean login(User user) {
        boolean flag=true;
        QueryWrapper<User> queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_name", user.getUserName());
        queryWrapper.eq("user_password", user.getUserPassword());

        List<User> users = this.baseMapper.selectList(null);
        users.forEach(System.out::println);

        User user1 = this.baseMapper.selectOne(queryWrapper);
        if(user1==null){
            flag=false;
        }
        return flag;
    }

    @Override
    public boolean updatePassword(User user) {
        int resultNum = this.baseMapper.updatePassword(user);
        if(resultNum>0){
            return true;
        }
        return false;
    }
}
